class Queue:
    def __init__(self, max_length = 10):
        print ("Building queue.")
        self.__index    = 0
        self.__elements = [0] * max_length
        
    def enqueue(self, value):
        if (not self.is_full()):
            self.__elements[self.__index] = value
            self.__index                 += 1
        
    def dequeue(self):
        if (not self.is_empty()):
            self.__index -= 1
            # Extract the element on zero position.
            element       = self.__elements[0]
            
            # Move the content of the elements to its previous position.
            counter = 1
            while  counter < self.__index + 1:
                self.__elements[counter - 1] = self.__elements[counter]
                counter                     += 1
            
            # The value is replaced by it's default.
            self.__elements[self.__index] = 0
            
            return element
    
    def top(self):
        if (not self.is_empty()):
            return self.__elements[self.__index - 1]
        else:
            return 0
    
    def is_empty(self):
        """
        If the stack is empty this method returns True, otherwise it will return
        False.
        """
        # If index is equals to 0 then the stack is empty.
        return self.__index == 0
    
    def is_full(self):
        """
        If the stack is full this method returns True, otherwise it will return
        False.
        """        
        return self.__index == len(self.__elements)
    
    def show(self):
        print (self.__elements)